package com.sailfish.springbootdemo.controller.db1;

import com.alibaba.fastjson.JSONArray;
import com.sailfish.springbootdemo.service.db1.CoreAlgorithmService;
import com.sailfish.springbootdemo.service.db1.ThirdApiSendService;
import com.sailfish.springbootdemo.service.db1.TimerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@RestController
@CrossOrigin
@RequestMapping("/test")
public class TestController {

    @Autowired
    private CoreAlgorithmService coreAlgorithmService;

    @Autowired
    private ThirdApiSendService thirdApiSendService;

    @GetMapping("/test1")
    public void test1() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cld = Calendar.getInstance();
        cld.setTime(new Date());
        cld.add(Calendar.MONTH, 1);
        Date d2 = cld.getTime();
        System.out.println(sdf.format(new Date()) + "加一月：" + sdf.format(d2));
    }

    @GetMapping("/test2")
    public String test2() {
        coreAlgorithmService.refreshDeviceUpkeepStatus(null);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return "刷新成功" + sdf.format(new Date());
    }

    @GetMapping("/test3")
    public JSONArray test3() {
        return thirdApiSendService.getAllPcbaRequestKey();
    }
}
